package m.server.web.req;

import m.system.util.StringUtil;

public enum ContentType {
    JSON("application/json"),
    URLENCODED("application/x-www-form-urlencoded"),
    FORM_DATA("multipart/form-data"),
    ;
    private final String text;
    ContentType(String t){
        this.text=t;
    }
    public boolean is(String contentType){
        if(StringUtil.isSpace(contentType)) return false;
        return contentType.trim().toLowerCase().startsWith(this.text.toLowerCase());
    }
    public static ContentType get(String contentType){
        for(ContentType type : values()){
            if(type.text.equals(contentType)) return type;
        }
        return null;
    }
}
